﻿Public Class GasInicio

    Private Sub GasInicio_Activated(sender As Object, e As EventArgs) Handles Me.Load
        If IsNothing(Util.CurrentParam) Then
            Using Form As New ParametrosForm
                Form.ShowDialog()
            End Using
        Else
            Me.Text = Util.CurrentParam.NOMBREEMPRESA
        End If
   

    End Sub

    Private Sub GasInicio_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Util.Pregunta("Realmente Desea Salir de la Aplicación") Then
            Dispose()
        Else
            e.Cancel = True
        End If
    End Sub


    Private Sub GasInicio_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ctl As Control
        Dim ctlMDI As MdiClient

        ' Loop through all of the form's controls looking
        ' for the control of type MdiClient.
        For Each ctl In Me.Controls
            Try
                ' Attempt to cast the control to type MdiClient.
                ctlMDI = CType(ctl, MdiClient)

                ' Set the BackColor of the MdiClient control.
                ctlMDI.BackColor = Me.BackColor

            Catch exc As InvalidCastException
                ' Catch and ignore the error if casting failed.
            End Try
        Next



    End Sub


    Private Sub ChoferesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChoferesToolStripMenuItem.Click
        Dim form As MantencionChoferes = Application.OpenForms.OfType(Of MantencionChoferes).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionChoferes
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub


    Private Sub ClientesToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClientesToolStripMenuItem1.Click
        Dim form As MantencionClientes = Application.OpenForms.OfType(Of MantencionClientes).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionClientes
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub


    Private Sub IngresarPedidoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IngresarPedidoToolStripMenuItem.Click
        Dim form As IngresoPedido = Application.OpenForms.OfType(Of IngresoPedido).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New IngresoPedido
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub ClientesToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CamionesToolStripMenuItem2.Click
        Dim form As MantencionCamiones = Application.OpenForms.OfType(Of MantencionCamiones).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionCamiones
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub VillasToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VillasToolStripMenuItem1.Click
        Dim form As MantencionVillas = Application.OpenForms.OfType(Of MantencionVillas).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionVillas
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub CallesToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CallesToolStripMenuItem1.Click
        Dim form As MantencionCalles = Application.OpenForms.OfType(Of MantencionCalles).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionCalles
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub GarantíasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GarantíasToolStripMenuItem.Click
        Dim form As MantencionGarantias = Application.OpenForms.OfType(Of MantencionGarantias).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionGarantias
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub ProveedoresToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProveedoresToolStripMenuItem.Click
        Dim form As MantencionProveedores = Application.OpenForms.OfType(Of MantencionProveedores).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionProveedores
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub ItemesToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItemesToolStripMenuItem1.Click
        Dim form As MantencionCargas = Application.OpenForms.OfType(Of MantencionCargas).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionCargas
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub IngresarFacturaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IngresarFacturaToolStripMenuItem.Click
        Dim form As IngresoFactura = Application.OpenForms.OfType(Of IngresoFactura).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New IngresoFactura
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub IngresarFacturaAtrasadaToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IngresarFacturaAtrasadaToolStripMenuItem1.Click
        Dim form As IngresoGuia = Application.OpenForms.OfType(Of IngresoGuia).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New IngresoGuia
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub


    Private Sub ConfiguraciónDeParámetrosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConfiguraciónDeParámetrosToolStripMenuItem.Click
        Dim form As ParametrosForm = Application.OpenForms.OfType(Of ParametrosForm).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New ParametrosForm
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub FormasDePagoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FormasDePagoToolStripMenuItem.Click
        Dim form As MantencionFormasPago = Application.OpenForms.OfType(Of MantencionFormasPago).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionFormasPago
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub GarantíasPrestadasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GarantíasPrestadasToolStripMenuItem.Click
        Dim form As GarantiasPendientes = Application.OpenForms.OfType(Of GarantiasPendientes).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New GarantiasPendientes
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub


    Private Sub DeudasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeudasToolStripMenuItem.Click
        Dim form As DeudasPendientes = Application.OpenForms.OfType(Of DeudasPendientes).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New DeudasPendientes
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub RealizarVentaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RealizarVentaToolStripMenuItem.Click
        Dim form As RealizarVenta = Application.OpenForms.OfType(Of RealizarVenta).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New RealizarVenta
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub GarantíasPrestadasToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GarantíasPrestadasToolStripMenuItem1.Click
        Dim form As Cierre = Application.OpenForms.OfType(Of Cierre).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New Cierre
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub SalirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalirToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub ModificarVentaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ModificarVentaToolStripMenuItem.Click
        Dim form As ModificarVenta = Application.OpenForms.OfType(Of ModificarVenta).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New ModificarVenta
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub VentasDePOSToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VentasDePOSToolStripMenuItem.Click
        Dim form As VentasPOS = Application.OpenForms.OfType(Of VentasPOS).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New VentasPOS
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub IniciarVentaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IniciarVentaToolStripMenuItem.Click
        Dim form As RealizarVentaDistribuidor = Application.OpenForms.OfType(Of RealizarVentaDistribuidor).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New RealizarVentaDistribuidor
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    'Private Sub CerrarVentaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    Dim form As CerrarVentaDistribuidor = Application.OpenForms.OfType(Of CerrarVentaDistribuidor).SingleOrDefault
    '    If IsNothing(form) Then
    '        Dim Formulario As New CerrarVentaDistribuidor
    '        Formulario.MdiParent = Me
    '        Formulario.Show()
    '    Else
    '        form.Activate()
    '    End If
    'End Sub

    Private Sub ListadoGeneralToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListadoGeneralToolStripMenuItem.Click
        Dim form As ListadoGeneral = Application.OpenForms.OfType(Of ListadoGeneral).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New ListadoGeneral
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub


    Private Sub RecibirGarantiasCambiadasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RecibirGarantiasCambiadasToolStripMenuItem.Click
        Dim form As GarantiasCambiadasForm = Application.OpenForms.OfType(Of GarantiasCambiadasForm).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New GarantiasCambiadasForm
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub DistribuidoresToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DistribuidoresToolStripMenuItem.Click
        Dim form As MantencionDistribuidores = Application.OpenForms.OfType(Of MantencionDistribuidores).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionDistribuidores
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub MantenciónDistribuidoresToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MantenciónDistribuidoresToolStripMenuItem.Click
        Dim form As MantencionDistribuidores = Application.OpenForms.OfType(Of MantencionDistribuidores).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionDistribuidores
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub

    Private Sub ToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem1.Click
        Dim form As MantencionClientesComerciales = Application.OpenForms.OfType(Of MantencionClientesComerciales).SingleOrDefault
        If IsNothing(form) Then
            Dim Formulario As New MantencionClientesComerciales
            Formulario.MdiParent = Me
            Formulario.Show()
        Else
            form.Activate()
        End If
    End Sub
End Class